package com.aaa.controller;

import com.aaa.entity.LayData;
import com.aaa.entity.MyPage;
import com.aaa.entity.TRole;
import com.aaa.service.TRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * (TRole)表控制层
 *
 * @author makejava
 * @since 2022-10-21 16:24:14
 */
@RestController
@RequestMapping("tRole")
public class TRoleController {
    /**
     * 服务对象
     */
    @Autowired
    private TRoleService tRoleService;

    //添加 and 修改
    @RequestMapping("add")
    public LayData add(TRole trole){
        return new LayData(tRoleService.add(trole));
    }
    //分页查询
    @RequestMapping ("query")
    public LayData query(MyPage myPage){
        return tRoleService.query(myPage);
    }
    //删除
    @RequestMapping("delete")
    public LayData delete(TRole trole){
        Boolean delete = tRoleService.delete(trole);
        return new LayData(delete);
    }
    @GetMapping
    public LayData queryAll(MyPage myPage){

        return new LayData(tRoleService.findAll(myPage));
    }
    @PostMapping("queryById")
    public LayData queryById(String rid){

        return tRoleService.queryById(rid);

    }
}
